<template>
	<view class="page">
		<view class="head">
			<u-search shape="square" height='80rpx' inputAlign="center" placeholder="搜索课程名称" :showAction="false"
				v-model="apiParams.title" @blur="refresh"></u-search>
		</view>

		<view class="list">
			<c-scroll-list ref="list" :option="{auto:false}" :api="api" :apiParams="apiParams" @load="load">
				<view class="t_list" v-for="(v,i) in courseList" :key="i"
					@click="$fn.jumpPage('/pages/home/pages/courseDetails?courseId='+v.id)">
					<view class="t_list_l">
						<view class="t_name">{{v.title}}</view>
						<view class="look_num">
							<u-icon name="eye" color="#999999" size="32rpx"></u-icon>
							{{v.viewNum>10000?(v.viewNum/10000).toFixed(1)+'w':v.viewNum}}
						</view>
					</view>
					<image class="t_img" :src="vuex_imgUrl+v.mainImages" mode=""></image>
				</view>
			</c-scroll-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				api: this.$api.getCourseList,
				apiParams: {
					isHot: 0, //1-推荐,0-正常
					title: '',
				},
				courseList: []
			}
		},
		onShow() {
			this.refresh()
		},
		methods: {
			// 刷新
			refresh() {
				setTimeout(() => this.$refs.list.initList(), 500)
			},

			load(res) {
				console.log('小程序课程列表-培训', res);
				this.courseList = res.list
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		display: flex;
		flex-direction: column;

		.head {
			background-color: #EF4630;
			padding: 24rpx;
			box-sizing: border-box;
			border-radius: 0rpx 0rpx 16rpx 16rpx;
		}

		.list {
			flex: 1;
			padding: 0 32rpx;
			box-sizing: border-box;

			.t_list {
				padding: 28rpx 0;
				border-bottom: 1rpx solid #E6E6E6;
				display: flex;
				align-items: center;
				gap: 34rpx;

				.t_list_l {
					flex: 1;
					height: 132rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.t_name {
						width: 100%;
						font-weight: 500;
						font-size: 28rpx;
						color: #333333;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 2;
						overflow: hidden;
						text-overflow: ellipsis;
					}

					.look_num {
						display: flex;
						align-items: center;
						gap: 10rpx;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
					}
				}

				.t_img {
					flex: none;
					width: 176rpx;
					height: 132rpx;
					border-radius: 4rpx;
				}

			}
		}
	}
</style>